<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Rtgm\sm;

class RtSm3
{
    public function digest($msg, $format = 1)
    {
        $md = [];
        $sm3 = new \Rtgm\smecc\SM3\SM3Digest();
        $msgArray = unpack("C*", $msg);
        $sm3->BlockUpdate($msgArray, 1, sizeof($msgArray));
        $sm3->DoFinal($md, 0);
        if($format) {
            return $this->_dec2hex($md);
        }
        return $md;
    }
    protected function _dec2hex($md)
    {
        $res = [];
        for ($i = 0; $i < count($md); $i++) {
            $res[$i] = sprintf("%02x", $md[$i]);
        }
        return implode("", $res);
    }
}

?>